package com.example.threadpool;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author shanchong
 * @date 2021/3/29
 **/
public class Main1 {

    public static void main(String[] args) {
        LinkedBlockingDeque<Runnable> workQueue = new LinkedBlockingDeque<>(1);
        ThreadPoolExecutor threadPoolExecutor =
                new ThreadPoolExecutor(1, 2,
                        1, TimeUnit.HOURS, workQueue);
        threadPoolExecutor.execute(()->{
            System.out.println("2222222222222");
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        threadPoolExecutor.execute(()->{
            System.out.println("333333333333");
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        threadPoolExecutor.execute(()->{
            System.out.println("4444444444444");
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        System.out.println();
    }

}
